import sqlite3
from bin.pymysqlmod import Pymysqlmod
from bin.Sheet import Sheetmod
from myconfig import  *
import re
def ReadDB(path: str):
    talbe= Sheetmod(Pymysqlmod(HOST, USER, PASSWORD, NAME), "bin_goods",
                        "01")
    conn = sqlite3.connect(path)
    cursor = conn.cursor()
    sqlstr = 'select id,cname,score,info_link,introduction,country,year_release ,category, pic_link  from movie250;'  # 填入SQL的查找命令
    cursor.execute(sqlstr)

    # 请选择其中一种读取方式
    '''
    #读取方法1：一次读取一条记录
    for item in cursor:
        print(item) #item返回一条记录
    '''

    '''
    #读取方法2：一次读取所有记录
    rows = cursor.fetchall() #rows返回所有记录，rows是一个二维列表
    '''
    all=cursor.fetchall()
    a=[
    "id",
    "name",
    "dyfs",
    "dylj",
    "dyjj",
    "dyly",
    "dysj",
    "dybq",
    "dytp"
    ]
    # print(all)
    for i in all:
        x=[]
        # print(i)
        j=0
        for ix in i:
            # print(ix)
            ix = " ".join(str(ix).split())#.split()
            # print(ix)
            x.append(ix)
        print(tuple(x))
        talbe.setdata(tuple(x))

    conn.commit()
    cursor.close()
    conn.close()
    return
if __name__ == "__main__":
    path = './movie.db'  # 填入db文件的路径
    ReadDB(path)

